<!--弹目-->
<div ng-if="pagedata.showtanmus && pagedata.setting.no_tanmu!=1" class="video-sms-pane {{pagedata.transition?'transition':''}}">
		<div class="video-sms-text">
			<image class="video-sms-logo" ng-src="{{pagedata.tanmus[pagedata.nowmsgid].avatar}}"/>
			<span class="overflow-h"> 最新订单来自 {{pagedata.tanmus[pagedata.nowmsgid].nickname}}</span>
		</div>
</div>
<script>
scope.pagedata.issocketmsg=false;
scope.pagedata.tanmuspage=0;
scope.pagedata.isa2=true;
scope.pagedata.isno_coupontop=1;
scope.pagedata.gettanmus=function() {
	if(!scope.pagedata.issocketmsg){
			scope.pagedata.nowmsgid=0;
			scope.get('jy_weishop/get_data/gettanmus/page='+scope.pagedata.tanmuspage,function(res){
						//console.log(res);
						scope.pagedata.tanmus=res.list
						if(scope.pagedata.tanmus.length>0){
							scope.pagedata.tanmuspage++;
							scope.pagedata.up_oldtanmu();
						}
			});
	}
}
//刚进入时；如果没有新订单消息，就弹储备订单消息
if(scope.pagedata.setting.no_tanmu!=1){
		setTimeout(function(){
			scope.pagedata.gettanmus();
		},3000);
}
scope.pagedata.up_oldtanmu=function() {
		if(scope.page.action=='index'){
			var i=scope.pagedata.nowmsgid;
			if(i<scope.pagedata.tanmus.length){
				set_tanmu(scope.pagedata.tanmus[i].nickname,scope.pagedata.tanmus[i].avatar,scope.pagedata.tanmus[i].time);
			}else{
				scope.pagedata.gettanmus();
			}
		}else{
			return false;
		}
}
function set_tanmu(nickname,avatar,time) {
		scope.pagedata.nowmsgid++
		scope.pagedata.showtanmus=true
		scope.$evalAsync(scope.pagedata.showtanmus);
		setTimeout(function(){
			scope.pagedata.transition=true
			scope.$evalAsync(scope.pagedata.transition);	
		},1000);
		setTimeout(function(){
			scope.pagedata.showtanmus=false
			scope.pagedata.transition=false
			scope.$evalAsync(scope.pagedata.showtanmus);	
		},8000);
		setTimeout(function(){
			//等待5秒，如果没有新的订单消息，就弹储备订单消息
			scope.pagedata.issocketmsg=scope.pagedata.issocketmsg?scope.pagedata.issocketmsg:false;
			if(!scope.pagedata.issocketmsg && scope.page.action=='index'){
				scope.pagedata.up_oldtanmu();
			}
		},5000);
}
// 百度地图API功能
if(!scope.pagedata.lat_lng && !scope.main.lat_lng){
	window.scope.location(function(re){
		if(re.lat_lng){
			scope.main.lat_lng=re.lat_lng;
			scope.main.pcd=re.addressComponents;
			scope.pagedata.pcd=re.addressComponents;
			scope.pagedata.pcd.street=scope.pagedata.pcd.street_recommend?scope.pagedata.pcd.street_recommend:scope.pagedata.pcd.street;
			var query=scope.made_query(scope.pagedata.pcd);
			query+='&'+'lat='+re.lat_lng.lat+'&lng='+re.lat_lng.lng+'&city='+scope.main.pcd.city;
			scope.get('jy_weishop/store.index/getlist/islocation=1&'+query,function(res){
				scope.pagedata.selectstore = res.stores?res.stores[0]:{};
				scope.$evalAsync();
			});
		}
	},scope.pagedata.setting.no_location);
}
//手机软键盘--搜索
$("body").keydown(function() {
    if (event.keyCode == "13") {
        $('#searchsub').click();
    }
});
scope.pagedata.scancode=function () {
			console.log('scanQRCodeOK');
			wx.scanQRCode({
				needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
				scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
				success: function (res) {
					var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
					location.href = result;
				}
			});
}
if(scope.main.uplookurl){
	scope.pagedata.nowmsgid=0;
	scope.main.uplooktime=scope.main.uplooktime?scope.main.uplooktime:10;
	var time=scope.main.uplooktime*1000
	setTimeout(function(){
		console.log('uplook');
		if(scope.main.uplookurl && scope.page.plugin=='jy_weishop' && scope.page.action=='index'){
			scope.get(scope.main.uplookurl,function(res){
				scope.message(res);
			});
		}
		scope.main.uplookurl=false
	},time);
}
</script>